package com.ustc.phoenix.controller;

import com.ustc.phoenix.models.Blog;
import com.ustc.phoenix.models.TestPojo;
import com.ustc.phoenix.mybatis.Mybatis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping(value="/users")
public class MyRestController {
    @Autowired
    Mybatis m;
    @RequestMapping(value="/{user}", method=RequestMethod.GET)
    public Blog getUser(@PathVariable Long user) {
        // ...
        Blog blog=null;
        //Mybatis m = new Mybatis();
        try {
            blog = m.selectBlog(1);
        }catch (Exception e){
            System.out.println(e.getStackTrace().toString());
            System.out.println(e.getMessage());
        }
    	return blog;
    }

    @RequestMapping(value="/{user}/customers", method=RequestMethod.GET)
    ArrayList<String> getUserCustomers(@PathVariable Long user) {
        // ...

    	return null;
    }

    @RequestMapping(value="/{user}", method=RequestMethod.DELETE)
    public TestPojo deleteUser(@PathVariable Long user) {
        // ...
        return null;
    }
}
